const express = require("express");
const router = express.Router();
// 导入文章的路由处理函数模块
const article_handler = require("../router_handler/article");
// 导入 multer 和 path
const multer = require("multer");
const path = require("path");

// 导入验证数据的中间件
const expressJoi = require("@escook/express-joi");
// 导入文章的验证模块
const { add_article_schema } = require("../schema/article");

// 创建 multer 的实例
const uploads = multer({ dest: path.join(__dirname, "../uploads") });
// 发布新文章
router.post(
  "/add",
  uploads.single("cover_img"),
  expressJoi(add_article_schema),
  article_handler.addArticle
);
module.exports = router;
